import { fetch } from '@/utils/fetch';
import { addPageParam } from '@/utils';
import store from '@/store';

export function getBusinessList(params = {}) {
  let url = `lsm-web/sml/query/app_line_${params.type}_info`;
  url += `?token=${store.getters.token}`;
  url += params.customerCode ? `&customerCodeLike=${params.customerCode}` : '';
  url += params.customerName ? `&customerNameLike=${params.customerName}` : '';
  // 数据专线 互联网专线 语音专线
  url += params.productNo ? `&productNoLike=${params.productNo}` : '';
  // 数据专线 电路名称
  url += params.circuitName ? `&circuitNameLike=${params.circuitName}` : '';
  // 互联网专线 客户IP地址（客户IP地址或地址段）、ONU_MAC地址
  url += params.customerIp ? `&customerIpLike=${params.customerIp}` : '';
  url += params.mac ? `&macLike=${params.mac}` : '';
  // 语音专线 码号段表
  url += params.code ? `&codeLike=${params.code}` : '';
  // APN专线 APN名称、APNID
  url += params.apnName ? `&apnNameLike=${params.apnName}` : '';
  url += params.apnId ? `&apnIdLike=${params.apnId}` : '';
  // 短信专线 企业代码、服务代码
  url += params.serviceCode ? `&serviceCodeLike=${params.serviceCode}` : '';
  url += params.enterpriseCode ? `&enterpriseCodeLike=${params.enterpriseCode}` : '';
  url += addPageParam(params.page, params.limit);
  return fetch({
    baseURL: process.env.VUE_APP_GATE_PATH,
    url,
    method: 'get'
  });
}

export function getPerf(params) {
  let url = `lsm-web/sml/query/app_perf_${params.type}_info`;
  url += `?startTime=${params.startTime}`;
  url += `&endTime=${params.endTime}`;
  url += `&productNo=${params.productNo}`;
  return fetch({
    baseURL: process.env.VUE_APP_GATE_PATH,
    url,
    method: 'get'
  });
}

export function getCustomerList(params = {}) {
  let url = 'lsm-web/sml/query/app_customer_';
  url += params.type === 'province' ? 'province_important' : 'city_info';
  url += `?token=${store.getters.token}`;
  url += params.customerName ? `&customerNameLike=${params.customerName}` : '';
  url += params.customerCode ? `&customerCodeLike=${params.customerCode}` : '';
  // 1对应金牌客户，2对应,银牌客户，3对应铜牌客户  4对应标准客户
  url += params.customerLevel ? `&customerLevel=${params.customerLevel}` : '';
  // 1对应金牌，2对应,银牌，3对应铜牌  4对应标准
  url += params.customerServiceLevel ? `&customerServiceLevel=${params.customerServiceLevel}` : '';
  url += params.customerCity ? `&customerCity=${params.customerCity}` : '';
  url += params.customerManager ? `&customerMangerLike=${params.customerManager}` : '';
  url += params.isAttention ? `&isAttention=${params.isAttention}` : '';
  url += addPageParam(params.page, params.limit);
  return fetch({
    baseURL: process.env.VUE_APP_GATE_PATH,
    url,
    method: 'get'
  });
}

export function updateAttentionCustomer(data) {
  let url = 'lsm-web/sml/update/app_customer_province_atttion';
  url += `?token=${store.getters.token}`;
  return fetch({
    baseURL: process.env.VUE_APP_GATE_PATH,
    url,
    method: 'post',
    data
  });
}

export function getBusinessStatistics(customerCode) {
  let url = 'lsm-web/sml/query/app_customer_service_statistics';
  url += `?token=${store.getters.token}`;
  url += `&customerCode=${customerCode}`;
  return fetch({
    baseURL: process.env.VUE_APP_GATE_PATH,
    url,
    method: 'get'
  });
}

export function getOrderStatistics(customerCode) {
  let url = 'lsm-web/sml/query/app_customer_order_statistics';
  url += `?token=${store.getters.token}`;
  url += `&customerCode=${customerCode}`;
  return fetch({
    baseURL: process.env.VUE_APP_GATE_PATH,
    url,
    method: 'get'
  });
}

export function getAlarmList(params = {}) {
  let url = `lsm-web/sml/query/app_customer_alarm_${params.type}`;
  url += `?token=${store.getters.token}`;
  url += params.customerCode ? `&customerCode=${params.customerCode}` : '';
  url += params.productNo ? `&productNoLike=${params.productNo}` : '';
  url += params.productNoLike ? `&productNoLike=${params.productNoLike}` : '';
  url += params.circName ? `&circName=${params.circName}` : '';
  url += params.warningNo ? `&warningNo=${params.warningNo}` : '';
  url += params.eventTimeStart ? `&eventTimeStart=${params.eventTimeStart}` : '';
  url += params.eventTimeEnd ? `&eventTimeEnd=${params.eventTimeEnd}` : '';
  url += addPageParam(params.page, params.limit);
  return fetch({
    baseURL: process.env.VUE_APP_GATE_PATH,
    url,
    method: 'get'
  });
}

// 专线拓扑
export function getBusinessTopo(serviceId) {
  return fetch({
    baseURL: process.env.VUE_APP_GATE_PATH,
    url: `easysightInt/rest/topo/get/${serviceId}?token=${store.getters.token}`,
    method: 'get'
  });
}

// 质量拔测 地市专线
export function getCitiesLine() {
  return fetch({
    baseURL: process.env.VUE_APP_GATE_PATH,
    url: 'lsm-web/sml/query/app_net_end_getHy_score',
    method: 'get'
  });
}

// 质量拔测 TOP10最差行业网站
export function getEndGuildWeb() {
  return fetch({
    baseURL: process.env.VUE_APP_GATE_PATH,
    url: 'lsm-web/sml/query/app_net_end_getGuildWeb',
    method: 'get'
  });
}

// 质量拔测 全省行业网站质量TOP10
export function getTopGuildWeb() {
  return fetch({
    baseURL: process.env.VUE_APP_GATE_PATH,
    url: 'lsm-web/sml/query/app_net_selectWebDetail',
    method: 'get'
  });
}

// 专题分析 沉默客户
export function getSlient(type) {
  let url = 'lsm-web/sml/query/app_getSlient';
  url += `?type=${type}`;
  return fetch({
    baseURL: process.env.VUE_APP_GATE_PATH,
    url,
    method: 'get'
  });
}

// 专题分析 超标专线信息明细
export function getExcessiveLine(params = {}) {
  let url = 'lsm-web/sml/query/app_servies_cityName';
  url += `?token=${store.getters.token}`;
  url += params.cityName ? `&cityName=${params.cityName}` : '';
  url += params.districtName ? `&districtName=${params.districtName}` : '';
  url += params.lineType ? `&lineType=${params.lineType}` : '';
  url += addPageParam(params.page, params.limit);
  return fetch({
    baseURL: process.env.VUE_APP_GATE_PATH,
    url,
    method: 'get'
  });
}

export function getCustomerVisit(params = {}) {
  let url = 'lsm-web/sml/query/app_customer_service_visit';
  url += `?token=${store.getters.token}`;
  url += params.customerName ? `&customerName=${params.customerName}` : '';
  url += params.customerCode ? `&customerCode=${params.customerCode}` : '';
  url += addPageParam(params.page, params.limit);
  return fetch({
    baseURL: process.env.VUE_APP_GATE_PATH,
    url,
    method: 'get'
  });
}

// 专题分析 超标城市信息
export function getExcessiveCity(params = {}) {
  let url = 'lsm-web/sml/query/app_servies_ESinformation';
  url += `?token=${store.getters.token}`;
  url += params.cityName ? `&cityName=${params.cityName}` : '';
  url += params.districtName ? `&districtName=${params.districtName}` : '';
  return fetch({
    baseURL: process.env.VUE_APP_GATE_PATH,
    url,
    method: 'get'
  });
}

// 全省业务概览
export function getOverViewProvince() {
  return fetch({
    baseURL: process.env.VUE_APP_GATE_PATH,
    url: 'lsm-web/sml/query/app_home_source_overview',
    method: 'get'
  });
}

// 地市客户数和业务数
export function getOverViewity() {
  return fetch({
    baseURL: process.env.VUE_APP_GATE_PATH,
    url: 'lsm-web/sml/query/app_source_overview_city',
    method: 'get'
  });
}

// 集客专线大会战明细
export function getBattleDetail(params) {
  let url = 'lsm-web/sml/query/app_group_battle_detail?';
  url += params.parentIndex ? `&parentIndex=${params.parentIndex}` : '';
  url += params.dateTime ? `&dateTime=${params.dateTime}` : '';
  return fetch({
    baseURL: process.env.VUE_APP_GATE_PATH,
    url,
    method: 'get'
  });
}

// 插入客户搜索
export function insertCustomerSearch(data) {
  return fetch({
    baseURL: process.env.VUE_APP_GATE_PATH,
    url: `lsm-web/sml/update/app_fastsearch_customer?token=${store.getters.token}`,
    method: 'post',
    data
  });
}

// 查询客户搜索列表
export function queryCustomerSearch() {
  return fetch({
    baseURL: process.env.VUE_APP_GATE_PATH,
    url: `lsm-web/sml/query/app_fastsearch_customer_search?loginName=${store.getters.loginName}`,
    method: 'get'
  });
}

// 插入专线搜索
export function insertLineSearch(data) {
  return fetch({
    baseURL: process.env.VUE_APP_GATE_PATH,
    url: `lsm-web/sml/update/app_fastsearch_line?token=${store.getters.token}`,
    method: 'post',
    data
  });
}

// 查询专线搜索列表
export function queryLineSearch() {
  return fetch({
    baseURL: process.env.VUE_APP_GATE_PATH,
    url: `lsm-web/sml/query/app_fastsearch_line_seach?loginName=${store.getters.loginName}`,
    method: 'get'
  });
}
